import { post } from '@/utils/httpRequest'
import { queryUserByIdUrl } from '@/api/api'

export const user = {
  state: {
    userInfo: null
  },
  mutations: {
    // 用户信息
    changeUserInfo (state, payload) {
      state.userInfo = payload
    }
  },
  actions: {
    async getUserDetailAsync ({ commit }) {
      const result = await post(queryUserByIdUrl, {})
      if (result.code === 200) {
        commit('changeUserInfo', result.data)
      }
    }
  }
}
